package hello

import (
	"context"
	"elem_svc/elem"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type Login2Logic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewLogin2Logic(ctx context.Context, svcCtx *svc.ServiceContext) *Login2Logic {
	return &Login2Logic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *Login2Logic) Login2(req *types.Login2Request) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	login2, err := l.svcCtx.ElemRpc.Login2(l.ctx, &elem.Login2Request{
		Account:  req.Account,
		Password: req.Password,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    500,
		}, nil
	}

	return &types.Response{
		Message: "登录成功",
		Data:    login2,
		Code:    200,
	}, nil
}
